package com.tledu.dao.impl;

import com.tledu.dao.IStudentDao;
import com.tledu.domain.Student;
import lombok.AllArgsConstructor;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.Collections;
import java.util.List;

/**
 * @author cyrus
 */
@AllArgsConstructor
public class StudentDaoImpl implements IStudentDao {

    private final JdbcTemplate jdbcTemplate;

    @Override
    public List<Student> findAll() {
        List<Student> list = jdbcTemplate.query("select * from student", new BeanPropertyRowMapper<>(Student.class));
        return list;
    }
}
